package com.gitee.neuray.security.wb.ribs.biz;

import com.gitee.neuray.security.common.biz.BaseBiz;
import com.gitee.neuray.security.common.msg.TableResultResponse;
import com.gitee.neuray.security.common.util.Query;
import com.gitee.neuray.security.common.util.UUIDUtils;
import com.gitee.neuray.security.wb.ribs.mapper.QtfyMapper;
import com.gitee.neuray.security.wb.ribs.vo.QtVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class QtfyBiz extends BaseBiz<QtfyMapper, QtVo> {
  @Autowired private QtfyMapper qtfyMapper;

  /**
   * 获取交通费信息
   *
   * @param query
   * @return
   */
  public TableResultResponse getQtInfo(Query query) {
    // query.put("staffId", request.getHeader("userId"));
    Page<Object> result = PageHelper.startPage(query.getPageNo(), query.getPageSize());
    List<QtVo> list = qtfyMapper.getQtInfo(query);
    return new TableResultResponse(
        result.getPageSize(), result.getPageNum(), result.getPages(), result.getTotal(), list);
  }

  /** 删除交通费信息 */
  public void delQt(String id) {
    super.deleteById(id);
  }

  /**
   * 修改交通费信息
   *
   * @param qtVo
   */
  public void updQt(QtVo qtVo) {
    super.updateSelectiveById(qtVo);
  }

  /**
   * 新增交通费
   *
   * @param qtVo
   */
  public void insertQt(QtVo qtVo) {
    String id = UUIDUtils.generateShortUuid();
    qtVo.setId(id);
    super.insertSelective(qtVo);
  }

  @Override
  protected String getPageName() {
    return null;
  }

  public List<QtVo> queryQt(QtVo qtVo){
    return qtfyMapper.queryQt(qtVo);
  }
}
